package com.project.common.controller;

import com.project.common.entity.PageVo;
import com.project.common.entity.SysMenus;
import com.project.common.entity.SysUsers;
import com.project.common.service.SysMenusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/sysMenus")
public class SysMenusController {
    @Autowired
    private SysMenusService  sysMenusService;
    @ResponseBody
    @GetMapping("/queryMenus.action")
    public List<SysMenus> queryMenus(HttpSession session){
        SysUsers user=(SysUsers) session.getAttribute("user");
        List<SysMenus> sysMenus = sysMenusService.queryMenu(user.getId());
//        System.out.println(sysMenus);
        return sysMenus;
    }
    @ResponseBody
    @PostMapping("/queryAllMenus.action")
    public PageVo<SysMenus> queryAllMenusAction(@RequestBody Map<String,String> map){
        PageVo<SysMenus> sysMenusPageVo = sysMenusService.queryAllMenus(map);
        return sysMenusPageVo;
    }
    @ResponseBody
    @PostMapping("/queryAllMenus")
    public PageVo<SysMenus> queryAllMenus(@RequestBody Map<String,String> map){
        PageVo<SysMenus> sysMenusPageVo = sysMenusService.queryAllMenus(map);
        return sysMenusPageVo;
    }

    @ResponseBody
    @PostMapping("/queryAllMenus1.action")
    public List<SysMenus> queryAllMenus1(){
        List<SysMenus> sysMenus = sysMenusService.queryAllMenus();
        return sysMenus;
    }
    @ResponseBody
    @PostMapping("/queryMenusByRoleId.action")
    public List<SysMenus> queryMenusByRoleId(Integer roleId){
        List<SysMenus> sysMenus = sysMenusService.queryMenusByRoleId(roleId);
        return sysMenus;
    }

}
